package com.ms.game.slot.base;

import java.math.BigDecimal;

import com.xpec.c4.db.model.basic.SlotBasicGameModel;
import com.xpec.c4.game.datamanager.agent.money.CoinType;

public class SlotBasicPourState 
{
	private SlotBasicGameModel model;
	
	private CoinType cointype;

	public CoinType getCointype() {
		return cointype;
	}

	public void setCointype(CoinType cointype) {
		this.cointype = cointype;
	}

	public SlotBasicGameModel getModel() {
		return model;
	}

	public void setModel(SlotBasicGameModel model) {
		this.model = model;
	}
	
	/**
	 * 初始化數值
	 * @param waterlevel
	 * @param base
	 * @param start
	 * @param total
	 * @param state
	 */
	public void initValue
	(
			BigDecimal waterlevel,
			BigDecimal base,
			BigDecimal start,
			BigDecimal total,
			String state
	)
	{
				
	}
	
	/**
	 * 吐水-基準點
	 * @return
	 */
	public BigDecimal getPourBase()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getPourBase()
				:
				model.getTrialpourBase()	
				;
	}
	
	/**
	 * 吐水-起始值
	 * @return
	 */
	public BigDecimal getPourStart()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getPourStart()
				:
				model.getTrialpourStart()
				;
	}
	
	/**
	 * 吐水-本次吐水總值
	 * @return
	 */
	public BigDecimal getPourTotal()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getPourTotal()
				:
				model.getTrialpourTotal()
				;
	}
	
	
	/**
	 * 水庫值
	 * @return
	 */
	public BigDecimal getWaterPool()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getWaterpool()
				:
				model.getTrialwaterpool()
				;
	}
	
	/**
	 * 吐水狀態
	 * @return
	 */
	public String getPourState()
	{
		return
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getPourState()
				:
				model.getTrialpourState()
				;
	}
	
	/**
	 * 當次水庫範圍
	 * @return
	 */
	public String getWaterRange()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getWaterpool_range()
				:
				model.getTrialwaterpool_range()
				;
	}
	
	/**
	 * 當次水庫回饋比
	 * @return
	 */
	public int getWaterFeedBack()
	{
		return 
				(cointype.getId() == CoinType.GOLD.getId())? 
				model.getWaterpool_feedback()
				:
				model.getTrialwaterpool_feedback()
				;
	}
	
	/**
	 * 吐水 - 設定基礎值
	 * @param value
	 */
	public void setPourBase(BigDecimal value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setPourBase(value);
		}
		else
		{
			model.setTrialpourBase(value);
		}
	}
	
	/**
	 * 吐水 - 設定起始值
	 * @param value
	 */
	public void setPourStart(BigDecimal value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setPourStart(value);
		}
		else
		{
			model.setTrialpourStart(value);
		}
		
	}
	
	/**
	 * 吐水 - 設定總值
	 * @param value
	 */
	public void setPourTotal(BigDecimal value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setPourTotal(value);
		}
		else
		{
			model.setTrialpourTotal(value);
		}
	}
	
	/**
	 * 水庫值
	 * @param value
	 */
	public void setWatePool(BigDecimal value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setWaterpool(value);
		}
		else
		{
			model.setTrialwaterpool(value);
		}
	}
	
	/**
	 * 吐水 - 設定狀態
	 * @param value
	 */
	public void setPourState(String value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setPourState(value);
		}
		else
		{
			model.setTrialpourState(value);
		}
	}
	
	/**
	 * 吐水 - 本次範圍
	 * @param value
	 */
	public void setWaterRange(String value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setWaterpool_range(value);
		}
		else
		{
			model.setTrialwaterpool_range(value);
		}
	}
	
	/**
	 * 吐水 - 本次回饋比
	 * @param value
	 */
	public void setWaterFeedBack(int value)
	{
		if(cointype.getId() == CoinType.GOLD.getId())
		{
			model.setWaterpool_feedback(value);
		}
		else
		{
			model.setTrialwaterpool_feedback(value);
		}
	}
	
	//金額太大吐不能出去
	public static boolean isScoreTooBig(int score , int pourvalue , int limitmoney)
	{
		if(score <= pourvalue+limitmoney)
		{
			return false;
		}
		
		return true;
	}
}
